# -*- coding: utf-8 -*-
"""
Created on Mon Mar 13 15:59:01 2023

@author: maomao
"""


import os
import matplotlib.pyplot as plt

import pandas as pd
import seaborn as sn

import numpy as np
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import rcParams
shuju = pd.read_excel('C:\\Users\\maomao\\Desktop\\计算碳排放驱动因素之间的相关性.xlsx')
df = shuju.iloc[: ,:]
data=df.corr(method='spearman')
print('x is:',data)
plt.rcParams['font.sans-serif']=['SimHei']  #图片显示中文
plt.rcParams['axes.unicode_minus'] =False #减号unicode编码
'''print(shuju)
shuju.isnull().sum()   #看下有没有缺失值：
print(shuju)'''
data.describe()  #查看数据描述
plt.figure(figsize=(25,20))

im=sns.heatmap(data = data,cmap="YlGnBu",fmt='.2f',annot=True,cbar=False,cbar_kws = { 'format':'%.2f','pad':0.1},vmin = -1,vmax = 1,xticklabels=True,yticklabels=True,annot_kws={'size':30,'weight':'bold', 'color':'yellow'}) 
cb=im.figure.colorbar(im.collections[0]) #显示colorbar
cb.ax.tick_params(labelsize=30) #设置colorbar刻度字体大小
im.set_title("碳排放驱动因素之间的相关性",
fontsize=30, fontweight="bold",pad=15)#主要是涉及到制图的标题

plt.xticks(fontsize=30)
plt.yticks(fontsize=40)
plt.savefig('E:/materials/500dpiHot.jpg', dpi=500, bbox_inches='tight')
plt.show()
print(1)
 #shuju.corr() ：计算各变量之间的相关系数

# 设置刻度字体大小


